package com.yq.design.command;

/**
 * @ClassName CommandClient
 * @Description 命令模式：使用命令模式
 * 场景：遥控器上第一排 灯 开和关
 * 第二排，tv 开关
 * 最后还有一个撤销
 * @Author yaoqiang
 * @Date 2021/8/20 14:51
 * @Version 1.0
 */
public class CommandClient {
    public static void main(String[] args) {
        //创建light对象
        Light light = new Light();
        //接受者
        Onlight onlight = new Onlight(light);
        Offlight offlight = new Offlight(light);
        //调用者
        RemoteController remoteController = new RemoteController();
        //设置第一排
        remoteController.setCommand(0, onlight, offlight);
        //执行功能
        remoteController.onButton(0);
        remoteController.offButton(0);
        remoteController.undoButton();


    }
}
